<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品详情页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <link rel="stylesheet" href="./shoppingCar.css">
</head>
<body>
    <div id="app">
        <!--商品详情页-->
        <div class="container" v-if="!isDisplayCar">
            <div class="phone" v-for="i in phoneList" :key="i.id">
                <img :src="i.imgSrc" alt="手机">
                <div class="price"><p>${{i.price}}</p></div>
                <div class="name"><p>{{i.name}}</p></div>
                <button @click="addCar(i)"  :class="{ 'btn-active': i.isActive }"  >加入购物车</button>
            </div>
        </div>
        <!--购物车图标-->
        <div class="shoppingCar">
            <button @click="displayCar">{{isDisplayCar==true?"返回":"购物车"}}</button>
        </div>
        <!--购物车页面-->
        <div class="car" v-if="isDisplayCar">
            <h1>购物车</h1>
            <div class="phoneCarTitle">
                <div class="check">勾选状态</div>
                <div class="phoneImg">手机图片</div>
                <div class="phoneName">手机名称</div>
                <div class="phonePrice">手机价格</div>
                <div class="phoneNum">手机数量</div>
                <div class="action">操作</div>
            </div>
            <div class="phoneCar" v-for="i in carList" :key="i.id">
                <input type="checkbox" id="checkbox" v-model="i.isSelect" @change="selectGood">
                <img :src="i.imgSrc" alt="手机">
                <div class="carName"><p>{{i.name}}</p></div>
                <div class="carPrice"><p>${{i.price*i.num}}</p></div>
                <div class="btnGroup">
                    <button @click="addPhone(i)">+</button>
                    <input type="text" v-model.number="i.num">
                    <button @click="jianPhone(i)">-</button>
                </div>
                <button class="delete" @click="deleteA(i)">删除</button>
            </div>
            <div class="total" >
                <input type="checkbox" v-model="selectAll" @change="selectAllGoods">全选
                <button class="deleteAll" @click="deleteAllGoods()">全部删除</button>
                <div class="totalPrice">
                    总计：{{totalPrice}}元
                    <button>立即购买</button>
                </div>
            </div>
        </div>
    </div>
    <script src="./shoppingCar.js"></script>
</body>
</html>
